import base from './base';
import { getAntd } from './convert';

// export const getoDocIframeUrl = (info) =>{
//     let url = info.docUrl+"?";
//     for(const key in info.docParam){
//         url += key+"="+encodeURIComponent(info.docParam[key])+"&"
//     }
//     return url;
// }

export const getoDocTopButtons = (info) =>{
	const { btnDisabled } = base.globalStore;
	const { Button } = getAntd();
    let btnArr = [];
    info && info.buttons && info.buttons.map(btn =>{
        if(btn.isshow === true)
            btnArr.push(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@lvg4jk@odocbtn`} type="primary" disabled={btnDisabled} onClick={()=>{window.oDocUtil.odocBtnEvent(btn.key)}}>{btn.title}</Button>);
    });
    return btnArr;
}

//显示文档 、正文
/**
 * params：
 * docid: 文档id
 * requestid:请求id
 * type:0 公文，1 文档
 */
window.addDocReadTag = (docId) =>{
	//DocReadTagUtil.addDocReadTag(docId,<%=user.getUID()%>,<%=user.getLogintype()%>,"<%=request.getRemoteAddr()%>",returnTrue);
}

export const showDoc = (params) =>{
	workflow_form_doc_operation.showDoc(params);
}

//创建文档、正文
export const createDoc = (fieldMark, commonParam) =>{
	const { workflowid,f_weaver_belongto_userid,f_weaver_belongto_usertype,newdocpath,secretLevel } = commonParam;
	let params = {};
	params.wfid  = workflowid;
	params.f_weaver_belongto_userid = f_weaver_belongto_userid;
	params.f_weaver_belongto_usertype = f_weaver_belongto_usertype;
	params.docfileid = fieldMark.substring(5);
	params.secid = newdocpath;
	params._secretLevel = secretLevel;
	workflow_form_doc_operation.createDoc(params); 
}
